package com.xiaoma.tpo.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.xiaoma.tpo.baseDao.BaseDaoImpl;
import com.xiaoma.tpo.baseDao.DefaultRowMapper;
import com.xiaoma.tpo.domain.BonusTaskRecord;
import com.xiaoma.tpo.dto.BonusBoard;

@Repository
public class BonusTaskRecordDao extends BaseDaoImpl<BonusTaskRecord>{

    @SuppressWarnings("unchecked")
    public List<BonusBoard> findTaskAchievements(int userId) {
        String sql = "select a.user_id, b.img, b.title, sum(b.bonus_point) as bonus_point from bonus_task_record a left join bonus_task b on a.task_id = b.id where a.user_id = ? group by b.task_rule_id";
        List<?> result = jdbcTemplate.query(sql, new DefaultRowMapper(BonusBoard.class, getNameHandler()), userId);
        return (List<BonusBoard>)result;
    }
}
